<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>login</title>
</head>
<body>

<center>
    <h3>登录页面</h3>
    <table border="1">
        <tr>
            <td>用户名</td>
            <td><input id="username" name="username" value="linchong"/></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input id="password" name="password" value="123456"/></td>
        </tr>
        <tr>
            <td colspan="2" align="right"><button id="submitBtn" onclick="login()">登录</button></td>
        </tr>
    </table>
</center>
</body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
    function login() {
        let username = $("#username").val();
        let password = $("#password").val();
        $.ajax({
            type: "POST",
            url: "/login",
            dataType:"json",
            data: {"username":username, "password":password},
            success: function(msg){
                location.href = "/index";
            },
            error:function(msg){
                alert("登录失败！！")
            }
        });
    }

</script>
</html>